package account.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JButton;


import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;

import dao.account.DataLayerAccount;
import account.docent.view.DocentView;
import account.model.SubTeam;
import account.model.InloggenModel;
import account.student.view.StudentView;
import account.student.view.StudentViewSmall;
import account.view.InloggenView;
import account.view.MailRecoveryView;
import mededelingen.view.TvView;
import tools.SplashFace;
import tools.language.MentionAccounts;
import tools.old.files.MainView;
import tools.old.files.TeacherFrame;
import tools.old.files.TeacherFrameExt;

public class InloggenController implements ActionListener{

	MailRecoveryView mrv;
	
	public InloggenController(JButton btnInloggen){}
	public InloggenController(JMenuItem mntmAfsluiten){}

	@Override
	public void actionPerformed(ActionEvent e) {
		//inlog controleren
		if("Inloggen".equals(e.getActionCommand())){
			LoginButton();
		}
		//app afsluiten
		if("Afsluiten".equals(e.getActionCommand())){
			System.exit(0);
		}
		//wachtwoordframe oproepen
		if("Wachtwoord".equals(e.getActionCommand())){
			RecoveryPassword();
		}
	}
	
	//TODO Kishan
	public InloggenController(){
		mrv = new MailRecoveryView();
	}

	//TODO Kishan
	public void RecoveryPassword(){
		mrv.run();
	}

	public boolean LoginButton(){
		String gebruikersnaam = InloggenView.getInstance().getGebruikersnaamTF().getText();
		char[] wachtwoord = InloggenView.getInstance().getWachtwoordTF().getPassword();

		//foutmelding indien gegevens niet zijn ingevuld
		if(gebruikersnaam.equals("") || wachtwoord.equals("") ){
			MentionAccounts.getInstance().errorRegistreren();
		} else {
			//check de inloggegevens
			InloggenModel.getInstance().Inloggen();
		}
		return false;
	}
}